import { _decorator, Component, Node, RigidBody, v3 } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('Duck')
export class Duck extends Component {
    public Speed: number = 20;//默认速度

    start() {
        this.schedule(() => {
            this.node.forward = this.node.forward.multiply(v3(1, 1, -1));
        }, 5)
    }

    update(deltaTime: number) {
        this.node.getComponent(RigidBody).setLinearVelocity(this.node.forward.negative().multiply(v3(1, 1, this.Speed * deltaTime)));
    }
}


